package da.metricscraft.information;

import java.util.ArrayList;
import java.util.HashMap;

import org.bukkit.util.Vector;
import org.w3c.dom.Document;

import da.metricscraft.threads.InformationGatherer;
import da.metricscraft.threads.InformationGatherer.Xmls;
import da.metricscraft.tools.XMLWriter;
import da.metricscraft.tools.XMLWriter.XMLData;


public class MovementInformation  implements Information {
	
	private String name;
	private Vector location;
	private int lifetime;
	private MoveActions action;
	public enum MoveActions{
		MINE,
		MINE_FINE,
		DIE,
		TAKE_DAMAGE,
		KILL,
		BUILD,
		CRAFT,
		MOVE,
		DEVELOP,
		NONE
	}
	public MovementInformation(String name, Vector location, int lifetime, MoveActions action){
		this.name = name;
		this.location = location;
		this.lifetime = lifetime;
		this.action = action;
	}
	public String getPlayer(){
		return name;
	}
	@Override
	public void process(InformationGatherer ig) {
		Document doc = ig.getXML(Xmls.MOVEMENT);
		HashMap<String, ArrayList<XMLData>> map = new HashMap<String, ArrayList<XMLData>>();
		ArrayList<XMLData> data = new ArrayList<XMLWriter.XMLData>();
		data.add(new XMLData("x", (int)location.getX() + ""));
		data.add(new XMLData("y", (int)location.getY() + ""));
		data.add(new XMLData("z", (int)location.getZ() + ""));
		data.add(new XMLData("lifetime", lifetime + ""));
		map.put(action.name(), data);
		XMLWriter.write(doc, map, "player", name, "player");
		
	}

}
